home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / cmln0186.arc / ARTINT1.LTG next >
Text File  |  1986-12-20  |  768b  |  20 lines

  1.  
  2.  
  3.                             Listing 1  
  4.                     Pattern Matcher in Prolog
  5.  
  6.  
  7.           [1]  match(X,X).
  8.           [2]  match(?,_).
  9.           [3]  match(*,_).
  10.           [4]  match([* | PT], E) :- append(_,ET,E), match(PT,ET).
  11.           [5]  match([PH | PT],[EH | ET]) :- match(PH,EH), match(PT,ET).
  12.  
  13.           In case your Prolog doesn't include the append predicate, here's
  14.           an implementation; it asserts that its third argument is a list
  15.           that is the result of appending its first two arguments.
  16.  
  17.                append([],L,L).
  18.                append([X|L1],L2,[X|L3]) :- append(L1,L2,L3).
  19.  
  20.